package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Home.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	import gs.events.TweenEvent;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.plaf.*;
	import org.aswing.skinbuilder.SkinProgressBarBackground;
	import org.aswing.skinbuilder.SkinProgressBarForeground;

	public class PanelMain extends JPanel
	{
		/**
		 * 地图显示器
		 */ 
		//private var _frameLogin:FrameLogin;
		//private var _frameRegister:FrameRegister;
		//private var _frameCreate:FrameCreate;

		//private var doc:DocumentClass;
		//private var _musicBackground:Music=new Music("background.mp3");
		public function PanelMain()
		{
			super();
			
			//Client.getInstance().addEventListener("1", FrameLogin.phLogin_1);
			Client.getInstance().addEventListener("2", FrameLogin.phLogout_2);
			Client.getInstance().addEventListener("5", FrameChar.phCharInfo_5);
			Client.getInstance().addEventListener("500", FrameChar.phUpdateCharInfo_500);
			Client.getInstance().addEventListener("6", SceneMain.phEnterMap_6);
			Client.getInstance().addEventListener("7", SceneMain.phLeaveMap_7);
			Client.getInstance().addEventListener("8", SceneMain.phMove_8);
			Client.getInstance().addEventListener("12", FrameTrends.phTrends_12);
			Client.getInstance().addEventListener("13", FrameBag.phItems_13);
			Client.getInstance().addEventListener("15", FrameBag.phUpdateItem_15);
			Client.getInstance().addEventListener("53", FrameBag.phAddItem_53);
			Client.getInstance().addEventListener("21", FrameChar.phSkills_21);
			Client.getInstance().addEventListener("100", FramePet.phPets_100);
			Client.getInstance().addEventListener("101", FramePet.phPetChangeName_101);
			Client.getInstance().addEventListener("102", FramePet.phPetJoinBattle_102);
			Client.getInstance().addEventListener("103", phPartnerWatch_103);
			Client.getInstance().addEventListener("200", FrameTeam.phTeamInvite_200);
			Client.getInstance().addEventListener("201", FrameTeam.phTeamInviteAnswer_201);
			Client.getInstance().addEventListener("202", FrameTeam.phTeam_202);
			Client.getInstance().addEventListener("203", FrameTeam.phTeamDestroy_203);
			Client.getInstance().addEventListener("207", FrameTeam.phTeamLeave_207);
			Client.getInstance().addEventListener("208", FrameTeam.phTeamKick_208);
			Client.getInstance().addEventListener("210", FrameTeam.phTeamWaitingList_210);
			Client.getInstance().addEventListener("212", FrameTeam.phTeamSoulInvite_212);
			Client.getInstance().addEventListener("214", FrameTeam.phTeamSoul_214);
			Client.getInstance().addEventListener("217", FrameTeam.phTeamSoul_217);
			Client.getInstance().addEventListener("218", FrameTeam.phJoinTeamSoul_218);
			Client.getInstance().addEventListener("300", SceneBattle.phEnterBattle_300);
			Client.getInstance().addEventListener("301", SceneBattle.phLeaveBattle_301);
			Client.getInstance().addEventListener("308", SceneBattle.phCompareInvite_308);
			//Client.getInstance().addEventListener("306", phBattleEnd_306);
			Client.getInstance().addEventListener("310", SceneBattle.phWatchBattle_310);
			Client.getInstance().addEventListener("311", SceneBattle.phWatchBattleExit_311);
			Client.getInstance().addEventListener("320", FrameBattleSetting.phBattleSetting_320);
			Client.getInstance().addEventListener("503", FrameAddStamina.phLackStamina_503);
			Client.getInstance().addEventListener("600", FrameFriend.phFriends_600);
			Client.getInstance().addEventListener("603", FrameFriendChat.phFriendChat_603);
			Client.getInstance().addEventListener("604", FrameFriend.phFriendUpdate_604);
			Client.getInstance().addEventListener("605", FrameWChar.phFriendWatch_605);
			Client.getInstance().addEventListener("800", FrameTrade.phTradeInvite_800);
			Client.getInstance().addEventListener("802", FrameTrade.phTradeStart_802);
			Client.getInstance().addEventListener("803", FrameTrade.phTradePrepare_803);
			Client.getInstance().addEventListener("804", FrameTrade.phTradeTrade_804);
			Client.getInstance().addEventListener("805", FrameTrade.phTradeCancel_805);
			Client.getInstance().addEventListener("806", FrameTrade.phTradeClose_806);
			Client.getInstance().addEventListener("900", FrameNPCDialog.phNPCDialog_900);
			Client.getInstance().addEventListener("902", FrameTalk.phTalk_902);
			Client.getInstance().addEventListener("903", FrameSubtitle.phSubtitle_903);

			Client.getInstance().addEventListener("1001", phInfo_1001);
			
			Client.getInstance().addEventListener("1100", FrameTask.phTask_1100);
			Client.getInstance().addEventListener("1102", FrameTask.phTaskRecordUpdate_1102);
			Client.getInstance().addEventListener("1104", FrameTask.phTaskAcceptable_1104);
			Client.getInstance().addEventListener("1106", FrameTask.phTaskCountEveryday_1106);
			
			Client.getInstance().addEventListener("1200", FrameLover.phLover_1200);
			Client.getInstance().addEventListener("1300", Home.phHomeEnter_1300);
			Client.getInstance().addEventListener("1301", Home.phHomeBuildings_1301);
			Client.getInstance().addEventListener("1309", Home.phHomePetBuyableItems_1309);
			
			Client.getInstance().addEventListener("1400", FramePair.phPairs_1400);
			Client.getInstance().addEventListener("1500", FrameSlave.phSlaves_1500);
			Client.getInstance().addEventListener("1503", FrameSlave.phSlavesCatch_1503);
			Client.getInstance().addEventListener("1600", FrameChar.phTitles_1600);
			Client.getInstance().addEventListener("1700", FrameBuff.phBuffs_1700);
			Client.getInstance().addEventListener("1800", FrameFaction.phFactionRank_1800);
			Client.getInstance().addEventListener("1803", FrameFaction.phFaction_1803);
			Client.getInstance().addEventListener("1901", phLevelup_1901);
			Client.getInstance().addEventListener("2000", FrameMining.phMining_2000);
			Client.getInstance().addEventListener("2100", FrameStall.phStall_2100);
			
			Client.getInstance().addEventListener("2200", SceneMain.phNPC_2200);
			Client.getInstance().addEventListener("2201", SceneMain.phUpdateNPC_2201);
			
			//component creation
			setSize(new IntDimension(1200, 600));
			var layout0:BorderLayout = new BorderLayout();
			setLayout(layout0);
			
			//doc = new DocumentClass();
			//addChild(doc);
			this.setClipMasked(false);
			
		}
		private static var _instance:* = null;
		public static function getInstance():PanelMain
		{
			if(_instance == null)
				_instance = new PanelMain();
			return _instance;
		}
		public function get isInBattle():Boolean
		{
			return _isInBattle;
		}
		
		//public function get sceneMain():SceneMain
		//{
		//	return _sceneMain;
		//}
		
		//public function get sceneBattle():SceneBattle
		//{
		//	return _sceneBattle;
		//}
		
		private var _isInBattle:Boolean = false;
		//public static var btn_battle_switchover:JButton = new JButton();
		public function enterBattle():void
		{
			if(_isInBattle)
			{
				return;
			}
			
			if(FrameTalk.isShowing())
				FrameTalk._frame.leave();
			if(FrameSubtitle.isShowing())
				FrameSubtitle._frame.leave();

			PanelMainHelp.getInstance().removeChild(SceneMain.getInstance());
			PanelMainHelp.getInstance().onEnterBattle();
			PanelMainHelp.getInstance().addChildAt(SceneBattle.getInstance(), 0);
			
			SceneBattle.getInstance().loadBattle(SceneMain.getInstance());
			SceneMain.getInstance().enable = false;
			SceneBattle.getInstance().enable = true;
			_isInBattle = true;

			SceneBattle.waitingLeaveBattle = false;
			FrameBattleAuto.update();
			CharInfo.objSelf.moveEnd();
		}
		
		public function leaveBattle():void
		{
			if(!_isInBattle)
			{
				return;
			}

			SceneBattle.getInstance().clearup();
			PanelMainHelp.getInstance().removeChild(SceneBattle.getInstance());
			SceneMain.getInstance().enable = true;
			SceneBattle.getInstance().enable = false;
			PanelMainHelp.getInstance().addChildAt(SceneMain.getInstance(),0);
			SceneMain.getInstance().enterEffect();
			_isInBattle = false;
			FrameBattle.hide();
			FrameBattle.hidePartner();
			SceneMain.getInstance().map.needUpdate = true;
			
			PanelMainHelp.getInstance().onLeaveBattle();
			//PanelMainHelp.getInstance().bringToBottom(SceneMain.getInstance());
			SceneMain.getInstance().checkNPCDialogTarget();
			FrameBattleAuto.hide();
			SceneBattle.waitingLeaveBattle = false;
			if(FrameFriend.isShowing())
			{
				FrameFriend.hide();
				FrameFriend.show();
			}
		}
		

		private function phInfo_1001(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phInfo_1001", msg);
			var nIndex:uint = 0;
			var type:int = msg[nIndex++];
			var info:String = msg[nIndex++];
			//PanelMain.showInfo(info);
			showInfoTimeLimit(info,type);
			FrameInfoMain.showInfoTimeLimit(info);
		}
		
		
		
		
		private var _listener:Boolean = false;
		public function setupListener():void
		{
			if(_listener) return;
			CharInfo.objSelf.scene.addEventListener(MouseEvent.CLICK,onClick,false,0,true);
			_listener = true;
			CharInfo.objSelf.onMoveEnd = SceneMain.getInstance().onMoveEnd;
		}
		public function unsetupListener():void
		{
			if(!_listener) return;
			CharInfo.objSelf.scene.removeEventListener(MouseEvent.CLICK,onClick);
			_listener = false;
		}
		
		public function onClick(e:MouseEvent):void
		{
			if(CharInfo.objSelf.scene == null)return;
			if(CharInfo.objSelf.scene.map == null)return;
			if(CharInfo.objSelf.scene.map.AStar == null)return;
			
			if(CharInfo.objSelf.scene == null)return;
			if(CharInfo.objSelf.following)return;
			
			var d:ObjectBase = ObjectBase._oldMouseOnObject;
			if(d!= null && d._renderBitmap != null && d._renderBitmap.visible && d.visible)
			{
					return;
			}
			
			// 计算世界坐标
			var target:Point = CharInfo.objSelf.scene.map.getWorldPostion(e.stageX,e.stageY);
			if(SceneMain.getInstance().objectClick != null)
			{
				SceneMain.getInstance().objectClick._frameCurrent = 0;
				SceneMain.getInstance().objectClick.setPos(target.x,target.y);
				SceneMain.getInstance().objectClick.visible = true;
			}
			// 计算格子数

			SceneMain.getInstance().onObjectMove(target);
		}
		
		
		
		
		public function updatePlayerMainImage():void
		{
			var arrayEquips:Array = new Array();
			
			if(CharInfo.m_nImageId != 0)
			{
				arrayEquips.push(Engine.assetMapMonsterPath + "npc_"+ CharInfo.m_nImageId + '.swf');
			}
			else
			{
				var nIndex:uint = 0;
				for each(var item:Object in CharInfo.m_arItemPage[0])
				{
					if(item.csv_id != 0)
					{
						var objItemCSV:Object = Client.getInstance().GetItemCSV(item.csv_id);
						arrayEquips.push(Engine.assetCharPath + "char_"+ CharInfo.m_nRace+ objItemCSV.require_gender+objItemCSV.equip_image_id + '.swf');
						
					}
					else
					{
						arrayEquips.push(Engine.assetCharPath + "char_"+ CharInfo.m_nRace+ CharInfo.m_nGender+'0' + '.swf');
					}
					
					nIndex++;
					if(nIndex >= 6)
						break;
				}
			}
			
			CharInfo.objSelf.load(arrayEquips,"char_"+ CharInfo.headId + '.swf');
		}
		
		
		public static function phLevelup_1901(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phLevelup_1901", msg);
			var nIndex:uint = 0;
			//var m_nCharId:int = msg[nIndex++];
			//var type:int = msg[nIndex++];
			
			var mc_effect:MovieClip = Client.getEffectElement("mc_effect_" + 2000000) as MovieClip;
			if(mc_effect == null)
				return;
			CharInfo.objSelf.addEffect(2000000,mc_effect);
		}
		
		public static var PARTNER_TYPE_NULL:int = 0;
		public static var PARTNER_TYPE_SLAVE:int = 1;
		public static var PARTNER_TYPE_LOVER:int = 2;
		public static var PARTNER_TYPE_PET:int = 3;
			
		public static function phPartnerWatch_103(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phPartnerWatch_103", msg);
			var nIndex:uint = 0;
			var m_nCharId:int = msg[nIndex++];
			var type:int = msg[nIndex++];
			
			var objPlayer:ObjectCharPlayer = null;
			if(type == PARTNER_TYPE_PET)
			{

				var pet_id:int = msg[nIndex++];
				if(pet_id== 0)
					return;
				name = msg[nIndex++];
				var image_id:int = msg[nIndex++];
				watch = msg[nIndex++];
				
				if(watch == 0)
				{
					objPet = SceneMain.getInstance().getObjectByPetId(pet_id) as ObjectCharPet;
					if(objPet == null)
					{
						trace("objPet == null");
						return;
					}
					objPet.follow(null);
					SceneMain.getInstance().removeObject(objPet);
					return;
				}
				else
				{
					objPlayer = SceneMain.getInstance().getObjectByCharId(m_nCharId);
					if(objPlayer == null)
					{
						trace("objPlayer == null");
						return;
					}
					var objPet:ObjectCharPet = null;
					
					objPet = SceneMain.getInstance().getObjectByPetId(pet_id) as ObjectCharPet;
					if(objPet == null)
					{
						objPet = SceneMain.getInstance().createCharPet(Engine.assetMapMonsterPath + "npc_"+ image_id + '.swf',"monster_"+ image_id + '.swf',name,new Point(objPlayer.getPos().x,objPlayer.getPos().y));
					}
					
					objPet.petId = pet_id;
					objPet.follow(objPlayer);
					objPet.setName(name);
					objPet.setTitle(objPlayer.getName()+"的宠物");
				}
			}

			var lover_char_id:int = 0;
			var name:String = '';
			var m_nRace:int = 0;
			var m_nGender:int = 0;
			var arEquips:Array = null;
			var nEquips:uint = 0;
			var watch:int = 0;
			var j:int = 0;
			var arrayEquips:Array = null;
			
			if(type == PARTNER_TYPE_LOVER)
			{
				var loverId:int = msg[nIndex++];
				if(loverId== 0)
					return;
				lover_char_id = msg[nIndex++];
				name = msg[nIndex++];
				m_nRace = msg[nIndex++];
				m_nGender = msg[nIndex++];
				arEquips = new Array();
				nEquips = msg[nIndex++];
				for(j = 0; j < nEquips; j++)
				{
					arEquips[j] =  msg[nIndex++];
				}
				
				watch = msg[nIndex++];
				objPlayer = SceneMain.getInstance().getObjectByCharId(m_nCharId);
				if(objPlayer == null)
				{
					trace("objPlayer == null,BATTLE_PARTNER_TYPE_LOVER");
					return;
				}
				var objLover:ObjectCharLover = null;
				if(watch == 0)
				{
					objLover = SceneMain.getInstance().getObjectByLoverId(loverId) as ObjectCharLover;
					if(objLover == null)
					{
						trace("objPet == null");
						return;
					}
					objLover.follow(null);
					SceneMain.getInstance().removeObject(objLover);
				}
				else
				{
					objLover = SceneMain.getInstance().getObjectByLoverId(loverId) as ObjectCharLover;
					if(objLover == null)
					{
						arrayEquips = new Array();
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[0] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[1] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[2] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[3] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[4] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[5] + '.swf');
						objLover = SceneMain.getInstance().createCharLover(arrayEquips,"char_"+ m_nRace + '.swf',name,new Point(objPlayer.getPos().x,objPlayer.getPos().y),m_nGender);
					}
					objLover.loverId = loverId;
					objLover.follow(objPlayer);
					objLover.setName(name);
					objLover.setTitle(objPlayer.getName()+"的情人");
				}
			}
			
			if(type == PARTNER_TYPE_SLAVE)
			{
				var slave_id:int = msg[nIndex++];
				if(slave_id== 0)
					return;
				lover_char_id = msg[nIndex++];
				name = msg[nIndex++];
				m_nRace = msg[nIndex++];
				m_nGender = msg[nIndex++];
				arEquips = new Array();
				nEquips = msg[nIndex++];
				for(j = 0; j < nEquips; j++)
				{
					arEquips[j] =  msg[nIndex++];
				}
				
				watch = msg[nIndex++];
				objPlayer = SceneMain.getInstance().getObjectByCharId(m_nCharId);
				if(objPlayer == null)
				{
					trace("objPlayer == null,BATTLE_PARTNER_TYPE_SLAVE");
					return;
				}
				var objSlave:ObjectCharSlave = null;
				if(watch == 0)
				{
					objSlave = SceneMain.getInstance().getObjectBySlaveId(slave_id) as ObjectCharSlave;
					if(objSlave == null)
					{
						trace("objSlave == null");
						return;
					}
					objSlave.follow(null);
					SceneMain.getInstance().removeObject(objSlave);
				}
				else
				{
					objSlave = SceneMain.getInstance().getObjectBySlaveId(loverId) as ObjectCharSlave;
					if(objSlave == null)
					{
						arrayEquips = new Array();
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[0] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[1] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[2] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[3] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[4] + '.swf');
						arrayEquips.push(Engine.assetCharPath + "char_"+ m_nRace + m_nGender + arEquips[5] + '.swf');
						objSlave = SceneMain.getInstance().createCharSlave(arrayEquips,"char_"+ image_id + '.swf',name,new Point(objPlayer.getPos().x,objPlayer.getPos().y),m_nGender);
					}
					objSlave.slaveId = slave_id;
					objSlave.follow(objPlayer);
					objSlave.setName(name);
					objSlave.setTitle(objPlayer.getName()+"的奴隶");
				}
			}
			
			if(m_nCharId == CharInfo.charId)
			{
				CharInfo.m_nBattlePartnerType = type;
				PanelMainHelp.getInstance().onPartnerInfoUpdate();
			
				if(FrameSlave.isShowing())
					FrameSlave._frame.update();
				
				if(FramePet.isShowing())
					FramePet._frame.update();
				if(FrameLover.isShowing())
					FrameLover._frame.update();
			}
		}
		
		/*public function showFrameRegister():void
		{
			if(_frameRegister == null)
			{
				_frameRegister = new FrameRegister();
				addChild(_frameRegister);
			}
			_frameRegister.show();
			showPanelMainHelp(false);
		}*/
		
		/*public function showFrameCreate():void
		{
			if(_frameCreate == null)
			{
				_frameCreate = new FrameCreate();
				addChild(_frameCreate);
			}
			setBackgroundDecorator(null);
			setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_create_background") as DisplayObject));
			_frameCreate.show();
			showPanelMainHelp(false);
		}*/
		
		/*public function showFrameLogin():void
		{
			FrameLogin.show();
			setBackgroundDecorator(null);
			setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_create_background") as DisplayObject));
			showPanelMainHelp(false);
		}*/
		public function showPanelMainHelp(show:Boolean):void
		{
			if(!containsChild(PanelMainHelp.getInstance()) && show)
				addChild(PanelMainHelp.getInstance());
			if(containsChild(PanelMainHelp.getInstance()) && !show)
				removeChild(PanelMainHelp.getInstance());
			PanelMainHelp.getInstance().setVisible(show);
		}
		
		public static function showInfo(info:String):void
		{
			FrameInfo.showMessageDialog("",info,null,null);
		}

		//static private var _showInfoCount:int = 0;
		public static function showInfoTimeLimit(message:String,type:int = Const.INFO_TYPE_FAILED):void
		{
			FrameInfoTimeLimit.show(message,type);
			return;
			/*_showInfoCount++;
			var _chatBubbles:JTextArea = new JTextArea();
			_chatBubbles.setEditable(false);
			_chatBubbles.setBorder( new EmptyBorder);
			_chatBubbles.setBackgroundDecorator(null);
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 14, false, false, false, false);
			filter = new GlowFilter(ASColor.YELLOW.getRGB(), 1, 2, 2, 10);
			_chatBubbles.setFont(font);
			_chatBubbles.setForeground(ASColor.BLACK);
			_chatBubbles.getTextField().filters = (new Array(filter));
			_chatBubbles.setHtmlText(message);
			PanelMainHelp.getInstance().addChild(_chatBubbles);
			_chatBubbles.pack();
			_chatBubbles.x = (PanelMainHelp.getInstance().width - _chatBubbles.width) / 2;
			_chatBubbles.y = (PanelMainHelp.getInstance().height-_chatBubbles.height)/2-100 + _chatBubbles.height*_showInfoCount;
			
			TweenLite.to(_chatBubbles, 5, {x:_chatBubbles.x, y:_chatBubbles.y-80,onComplete:function(chatBubbles:JTextArea):void
			{
				if(PanelMainHelp.getInstance().containsChild(chatBubbles))
					PanelMainHelp.getInstance().removeChild(chatBubbles);
				_showInfoCount--;
			},onCompleteParams:[_chatBubbles]});*/
			
		}
		
		static private var _showSystemMessageCount:int = 0;
		public static function showSystemMessage(message:String):void
		{
			_showSystemMessageCount++;
			var _chatBubbles:JTextArea = new JTextArea();
			_chatBubbles.setEditable(false);
			_chatBubbles.setBorder( new EmptyBorder);
			_chatBubbles.setBackgroundDecorator(null);
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 24, true, false, false, false);
			filter = new GlowFilter(ASColor.BLACK.getRGB(), 1, 2, 2, 10);
			_chatBubbles.setFont(font);
			_chatBubbles.setForeground(ASColor.YELLOW);
			_chatBubbles.getTextField().filters = (new Array(filter));
			_chatBubbles.setHtmlText(message);
			PanelMainHelp.getInstance().addChild(_chatBubbles);
			_chatBubbles.pack();
			_chatBubbles.x = (PanelMainHelp.getInstance().width - _chatBubbles.width) / 2;
			_chatBubbles.y = (PanelMainHelp.getInstance().height-_chatBubbles.height)/2-80 + _chatBubbles.height*_showSystemMessageCount;;
			
			TweenLite.to(_chatBubbles, 5, {x:_chatBubbles.x, y:_chatBubbles.y-50,onComplete:function(chatBubbles:JTextArea):void
			{
				//if(PanelMainHelp.getInstance().containsChild(chatBubbles))
				//	PanelMainHelp.getInstance().removeChild(chatBubbles);
				
				TweenLite.to(chatBubbles, 0.5, {autoAlpha:0,onComplete:function(p:JTextArea):void
				{
					if(PanelMainHelp.getInstance().containsChild(p))
						PanelMainHelp.getInstance().removeChild(p);
					_showSystemMessageCount--;
				},onCompleteParams:[chatBubbles]});
				
			},onCompleteParams:[_chatBubbles]});
			
			
		}
	}
}